<div class="content">
    <div class="panel panel-info">
	    <div class="panel-heading">
	      <h3 class="panel-title">订单详情</h3>
	    </div>
	    <div class="panel-body">
	     	<table class="table table-condensed table-striped">
			   <thead>
			      <tr>
			         <th>订单号</th>
			         <th>订单总额</th>
			         <th>订单下单时间</th>
			         <th>订单状态</th>
			      </tr>
			   </thead>
			   <tbody>
			      <tr>
			         <td><?php echo $order_info['order_number']?></td>
			         <td><?php echo $order_info['order_total']?></td>
			          <td><?php echo date("Y-m-d H:i:s",$order_info['createdon'])?></td>
			         <td>
			         	<select  class="change_state" data-id="<?php echo $order_info['order_number']?>">
			         		<option value="1" <?php if($order_info['order_state']=="1"):?> selected=selected<?php endif;?>>Pending</option>
			         		<option value="2" <?php if($order_info['order_state']=="2"):?> selected=selected<?php endif;?>>Processing</option>
			         		<option value="3" <?php if($order_info['order_state']=="3"):?> selected=selected<?php endif;?>>Delivery</option>
			         		<option value="4" <?php if($order_info['order_state']=="4"):?> selected=selected<?php endif;?>>Complete</option>
			         		<option value="5" <?php if($order_info['order_state']=="5"):?> selected=selected<?php endif;?>>Cancel</option>
			         	</select>
			         </td>
			      </tr>
			   </tbody>
			</table>
	    </div>
	</div>
	<div class="panel panel-info">
	    <div class="panel-heading">
	      <h3 class="panel-title">地址</h3>
	    </div>
	    <div class="panel-body">
	    	<p>
                <span>UserName:</span>
                <span><?php echo $order_info['shipping_firstname'].' '.$order_info['shipping_lastname']?></span>
            </p>
            <p>
                <span>Phone:</span>
                <span><?php echo $order_info['shipping_phone']?></span>
            </p>
            <p>
                <span>Address:</span>
                <span><?php echo $order_info['shipping_address1']." "
                        .$order_info['shipping_city']." ".$order_info['shipping_state']." ".$order_info['shipping_country']."( "
                        .$order_info['shipping_postal_code']." )";?></span>
            </p>
	    </div>
	</div>
	<div class="panel panel-info">
	    <div class="panel-heading">
	      <h3 class="panel-title">订单产品</h3>
	    </div>
	    <div class="panel-body">
	     	<table class="table table-condensed table-striped">
			   <thead>
			      <tr>
			         <th>sku</th>
			         <th>产品名称</th>
			         <th>图片</th>
			         <th>价格</th>
			         <th>数量</th>
			         <th>属性</th>
			      </tr>
			   </thead>
			   <tbody>
			   	  	<?php if(!empty($order_item)):?>
			   	  	<?php foreach ($order_item as $ikey => $item):?>
				        <tr>
				         	<td><?php echo $item['sku']?></td>
				         	<td><?php echo $item['name']?></td>
				         	<td><img  width="100" height="100" src='<?php echo '/'.$item['image']?>' /></td>
				         	<td><?php echo $item['price']?></td>
				         	<td><?php echo $item['qty']?></td>
				         	<td><?php echo $item['attributes']?></td>
				        </tr>
				    <?php endforeach;?>
			  		<?php endif;?>
			   </tbody>
			</table>
	    </div>
	</div>
</div>
<script type="text/javascript">
	$(".change_state").on("change",function(){
		var order_state=$(this).val();
		var order_number=$(this).attr("data-id");
		if(confirm('确认更改订单状态？')){
			$.post("/order/updateState",{'order_number':order_number,'order_state':order_state},function(result){
				if(result.code=="0x00000"){
					alert("修改成功！");
				}
				else{
					alert("系统错误，修改失败！");
				}
			},'json').error(function(){
				alert("系统错误！");
			});
		}
	});
</script>